<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function removeDuplicates(coordsStr) {
        const coordsList = coordsStr.trim().split(';');
        const uniqueCoords = [];
        for (const coord of coordsList) {
            if (!uniqueCoords.includes(coord)) {
                uniqueCoords.push(coord);
            }
        }
        return uniqueCoords.join(';');
    }

    let str = "120.587038,31.303132;120.570516,31.297388;120.592488,31.293061;120.595149,31.300652;\n" +
        "120.587038,31.303132;120.570516,31.297388;120.592488,31.293061;120.595149,31.300652;\n" +
        "120.587038,31.303132;120.570516,31.297388;120.592488,31.293061;120.595149,31.300652;\n" +
        "120.587038,31.303132;120.570516,31.297388;120.592488,31.293061;120.595149,31.300652"

    console.log("原数组是:", str)

    console.log("处理后是:", removeDuplicates(str))


    formatDate = (msStr, format) => {
        const date = new Date(msStr / 1)
        let fmt = format
        const obj = {
            'M+': date.getMonth() + 1, // 月份
            'd+': date.getDate(), // 日
            'h+': (date.getHours() - 8) % 24, // 小时
            'm+': date.getMinutes(), // 分
            's+': date.getSeconds(), // 秒
        }
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, String(date.getFullYear()).substr(4 - RegExp.$1.length))
        }
        const keys = Object.keys(obj)
        for (let i = 0; i <= keys.length; i += 1) {
            const k = keys[i]
            if (new RegExp(`(${k})`).test(fmt)) {
                fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? obj[k] : `00${obj[k]}`.substr(String(obj[k]).length))
            }
        }
        return date.getFullYear() + "-" + fmt
    }

    const s1 = "2023-07-23T08:27:32Z"
    const s2 = "2023-07-23T08:55:32Z"

    const diff = Date.parse(s2) - Date.parse(s1)
    console.log(s1, s2, diff)
    console.log(formatDate(diff / 2 + Date.parse(s1), "MM-dd hh:mm:ss"))

</script>
</body>
</html>
